package com.moon.controller;

import com.moon.anno.UserName;
import com.moon.domain.People;
import com.moon.service.HelloService;
import com.moon.service.LuckBallService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * @author ：xxx
 * @description：TODO
 * @date ：2024/04/07 13:39
 */
@RestController
@Slf4j
public class TestController {

    @Autowired
    private HelloService helloService;

    @Resource
    private LuckBallService luckBallService;

//    @Autowired
//    private ChangeFateService changeFateService;

    @RequestMapping("/hello")
    public String sayHello(@UserName People People, String name) {
        log.info(name);
        return "你好" + name + People;
    }

    @RequestMapping("/sayHello")
    public void sayHello(String name) {
        String result = helloService.sayHello(name);
        System.out.println(result);
    }

//    @RequestMapping("/getDoubleColorBall")
//    public ArrayList<String> getDoubleColorBall() {
//        return changeFateService.generateRedAndBlueNumbers();
//    }

    @RequestMapping("/gril")
    public String gril() {
        StringBuilder s = new StringBuilder();
        for (int i = 0; i < 100; i++) {
            s.append("唐德萍，大美女1212" + System.lineSeparator());
        }
        return s.toString();
    }

    @RequestMapping("/luckball")
    public List<List<String>> getLuckBall(@RequestParam(required = false) Integer num){
        log.info("=========调用了幸运双色球接口=============" + num);
        ArrayList<List<String>> result = new ArrayList<>();
        for (int i = 0; i < (Objects.isNull(num) ? 1 : num); i++) {
            result.add(luckBallService.generateDoubleColorBall());
        }
        return result;
    }
}
